package com.yxt.admin.controller;

import com.yxt.admin.entity.GeneratorEntity;
import com.yxt.admin.service.GeneratorService;
import com.yxt.common.utils.ajax.PageUtils;
import com.yxt.common.utils.ajax.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 
 *
 * @author august
 * @email 379249906@qq.com
 * @date 2020-08-22 16:47:32
 */
@RestController
@RequestMapping("admin/generator")
public class GeneratorController {
    @Autowired
    private GeneratorService generatorService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = generatorService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		GeneratorEntity generator = generatorService.getById(id);

        return R.ok().put("generator", generator);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody GeneratorEntity generator){
		generatorService.save(generator);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody GeneratorEntity generator){
		generatorService.updateById(generator);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		generatorService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
